﻿using System.Linq;
using Kratos.Framework.ContentManagement.Models.Order;
using Kratos.Framework.Repositories;
using Kratos.Modules.Order.Repositories;

namespace Kratos.Modules.Order.Services.Impl
{
    public class ProductService : IProductService
    {
        private readonly IRepository<Product> _procuctRepository;

        public ProductService(IRepository<Product> procuctRepository)
        {
            _procuctRepository = procuctRepository;
        }

        public IQueryable<Product> GetAll()
        {
            return _procuctRepository.GetAll();
        }

        public void Save(Product model)
        {
            _procuctRepository.SaveOrUpdate(model);
        }

        public void Delete(Product model)
        {
            _procuctRepository.DeleteOnSubmit(model);
        }

        public Product GetProductById(int id)
        {
            return _procuctRepository.GetAll().GetProducyById(id);
        }
    }
}
